<template>
	<view>
		<view>
			<navbar  title="商家流水" :isGoBack="true" :isNotice="true" ></navbar>
		</view>		
		<view>
		  <swiper class="tab-content"  duration="300" bindchange="changeTab" :style="{'height':winHeight+'px'}">
				<!-- 全部 -->
				<swiper-item>
					<scroll-view :scroll-y="true" class="new-list-box" @scrolltolower="allLoadMore" scroll-top="scrollTop" scroll-with-animation :refresher-enabled="true" refresher-threshold="80" refresher-default-style="white" refresher-background="white" :refresher-triggered="triggered" @refresherrefresh="onAllRefresh">
						<view class="new-list-item" v-for="(item,index) in allTabList" :key="index">   
							 <view class="item-tag dis-flex-between">                    
								 <view class="content-deadline mb-15 text-xsl">交易时间：{{item.add_time}}</view>
								 <view class="content-deadline">类型：{{item.moneyType_name}}</view>                            
							 </view>
							 <view class="item-tag dis-flex-between">
							   <view class="content-deadline mb-15" style="color: red;font-weight: bold;font-size: 28rpx;" v-if="item.style == '1'">+ {{item.affectMoney}}</view>
							   <view class="content-deadline mb-15" style="color: gray;font-weight: bold;font-size: 28rpx;" v-if="item.style == '0'">- {{item.affectMoney}}</view>
							 <view class="content-deadline">余额：{{item.accountMoney}}</view>
						   </view>
						  </view>						  																	  
					</scroll-view>
				</swiper-item>       
			</swiper>				
		</view>	
	</view>	
</template>
<script>
	export default {
			data() {
				return {
					
					pageNo:1,
					allTabList:[],
					winHeight:'',
					scrollTop: 0, // 设置竖向滚动条位置
					triggered: false, // 下拉是否激活
					recordCount:1,
					infoType:1
				}
			},
			onLoad(options) {
				let height = uni.getSystemInfoSync().windowHeight;
				this.winHeight = (height - 150);			
				this._requestPageList(true);
				if(options.type){
				    this.infoType=options.type
				}
			},
			methods:{
				changeNav(e){
					let currentIndex = e.target.dataset.current;
					if (this.currentTab == currentIndex) {      
					    return false;
					} else {
					    this.pageNo=1;
						this.currentTab= currentIndex
					}
					this.allTabList=[];
					this._requestPageList(true);
				},			
				
				// 参数
				_requestPageList(isLoadMore = false, callback) {
				  if(!isLoadMore){
					this.allTabList=[]; // 全部       
					this.pageNo= 1;
					
				  }
				  let opt = {
					pageNo :this.pageNo,				
					token:uni.getStorageSync('userInfo').app_openid,
					login_type:'app',
					
				  }    
				  this._requestPageListCom("virtualTaskList", opt, callback);
				},
				// 列表接口
				_requestPageListCom(url, params, callback) {    
				  this.$http.moneyshoplog_list(params).then(res => {
					if (res.resCode == "9999") {
					  let oldList = [];
					  oldList = this.allTabList;       
					  const newGoodsList = res.data.list
					  const allData = [...oldList, ...newGoodsList]
					  // console.log(allData,'allData')     
					  this.allTabList=allData
					  this.recordCount=res.data.page
					  if(callback && typeof callback === 'function'){
						callback()
					  }
					}
				  })
				},			  
				// 上拉加载  滚动到底部/右边时触发
				allLoadMore(e){
					let _self = this;
					if (this._allLoadMore) return
					this._allLoadMore = true;
					this.pageNo= ++_self.pageNo				
					this._requestPageList(true, () => {
					  _self._allLoadMore = false;
					});
				},
				
				// 下拉刷新接口
				onAllRefresh() {
				 // 开启下拉自定义样式
					this.triggered = true;
		            this.pageNo=1;
					this._requestPageList(false, () => {
						// 当处理完数据刷新后，wx.stopPullDownRefresh可以停止当前页面的下拉刷新
						this.triggered = false;
					});    
				}				
			}
		}
</script>

<style>
	@import "./index.css";
</style>